﻿using System.IO;
using System.Linq;
using System.Reflection;
using Framework.Core.Dependency.Domain;
using Framework.Core.Dependency.Parser;
using Xunit;
using Xunit.Extensions;

namespace Framework.Tests.Core.Dependency
{
    public class CppProjectParserTest
    {
        private readonly CppProjectParser target;

        public CppProjectParserTest()
        {
            target = new CppProjectParser();
        }

        [Theory]
        [InlineData("MUDScriptParser.vcxproj", "MUDScriptParser", Language.Cpp, 30, 16)]
        [InlineData("MUDExoticCorporate.vcproj", "MUDExoticCorporate", Language.Cpp, 31, 33)]
        public void Should_test_cpp_parser(string projectName, string expectedProjectName, Language expectedLanguage, int expectedModuleCount, int expectedFilesCount)
        {
            var project = target.Parse(GetProject(projectName), projectName, "pouet");

            Assert.NotNull(project);

            Assert.Equal(expectedProjectName, project.Name);
            Assert.Equal(expectedLanguage, project.Language);
            Assert.Equal(expectedModuleCount, project.Modules.Count());
            Assert.Equal(expectedFilesCount, project.Files.Count);
        }

        private static Stream GetProject(string ressourceName)
        {
            var project = Assembly.GetExecutingAssembly().GetManifestResourceStream("Framework.Tests.Core.Dependency.CppProj." + ressourceName);

            Assert.NotNull(project);

            return project;
        }
    }
}
